package cn.golxen.barcode.exception;

import cn.golxen.commons.entity.Result;
import cn.golxen.commons.exception.BarcodeException;
import cn.golxen.commons.exception.BarcodeInfoException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionController {

    @ExceptionHandler(value = {BarcodeException.class})
    public Result barcodeException(BarcodeException e){
        return new Result(e.getCode(),e.getMessage());
    }

    @ExceptionHandler(value = {BarcodeInfoException.class})
    public Result barcodeInfoException(BarcodeInfoException e){
        return new Result(e.getCode(),e.getMessage());
    }
}
